package com.andy.mvp;


import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import com.andy.app_core.net.rx.RxRestClient;
import com.andy.mvp.poetry.PoetryActivity;

import java.util.HashMap;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;


public class LoginActivity extends AppCompatActivity {
    String username;
    String pwd;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        username=((EditText)findViewById(R.id.nameEt)).getText().toString();
        pwd=((EditText)findViewById(R.id.pwdEt)).getText().toString();
    }


    public void onClick(View view) {
        Intent intent=new Intent(LoginActivity.this, PoetryActivity.class);
        startActivity(intent);

//        HashMap<String,Object> params=new HashMap<>();
//        params.put("name",username);
//        params.put("passwd",pwd);
////        RestClient.create()
////                .url("developerLogin")
////                .parms(params)
////                .success(new ISuccess() {
////                    @Override
////                    public void onSuccess(String response) {
////                        System.out.println("====请求成功====="+response.toString());
////                    }
////                })
////                .error(new IError() {
////                    @Override
////                    public void onError(int code, String msg) {
////                        System.out.println("====请求失败====="+code+":"+msg);
////                    }
////                })
////                .build().post();
//
//        RxRestClient.create().url("developerLogin").parms(params).build().post()
//                .subscribeOn(Schedulers.io())
//                .observeOn(AndroidSchedulers.mainThread())
//                .subscribe(new Observer<String>() {
//                    @Override
//                    public void onSubscribe(Disposable d) {
//
//                    }
//
//                    @Override
//                    public void onNext(String s) {
//                        Toast.makeText(LoginActivity.this, "请求成功:"+s, Toast.LENGTH_SHORT).show();
//                        Intent intent=new Intent(LoginActivity.this, PoetryActivity.class);
//                        startActivity(intent);
//                    }
//
//                    @Override
//                    public void onError(Throwable e) {
//
//                    }
//
//                    @Override
//                    public void onComplete() {
//
//                    }
//                });
    }
}
